home *** CD-ROM | disk | FTP | other *** search
/ Dr. Windows 3 / dr win3.zip / dr win3 / PROGRAMR / OLE2BOOK.ZIP / CHAP13.ZIP / PATRON / PAGES.H < prev    next >
C/C++ Source or Header  |  1993-06-27  |  13KB  |  386 lines

  1. /*
  2.  * PAGES.H
  3.  * Modifications for Chapter 13
  4.  *
  5.  * Definitions and function prototypes for the Pages window control
  6.  * as well as the CPage class.
  7.  *
  8.  * Copyright (c)1993 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Software Design Engineer
  11.  * Microsoft Systems Developer Relations
  12.  *
  13.  * Internet  :  kraigb@microsoft.com
  14.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  15.  */
  16.  
  17.  
  18. #ifndef _PAGES_H_
  19. #define _PAGES_H_
  20.  
  21. //We need this for UICursorLoad and new-style cursors.
  22. #include <bttncur.h>
  23.  
  24. //CHAPTER13MOD
  25. #include <stdlib.h>     //For atol
  26. //End CHAPTER13MOD
  27.  
  28. //Versioning.
  29. #define VERSIONMAJOR                2
  30. #define VERSIONMINOR                0
  31. #define VERSIONCURRENT              0x00020000
  32.  
  33. //Classname
  34. #define SZCLASSPAGES                "pages"
  35.  
  36. #define HIMETRIC_PER_INCH           2540
  37. #define LOMETRIC_PER_INCH           254
  38. #define LOMETRIC_BORDER             60          //Border around page
  39.  
  40.  
  41. //Window extra bytes and offsets
  42. #define CBPAGESWNDEXTRA             (sizeof(LONG))
  43. #define PAGEWL_STRUCTURE            0
  44.  
  45.  
  46. //Time to break this stuff out into another file.
  47. #include "tenant.h"
  48.  
  49.  
  50. typedef struct __far tagTENANTLIST
  51.     {
  52.     DWORD       cTenants;
  53.     DWORD       dwIDNext;
  54.     } TENANTLIST, FAR *LPTENANTLIST;
  55.  
  56.  
  57. /*
  58.  * Persistent information we need to save for each tenant, which is done
  59.  * in the tenant list instead of with each tenant.  Since this is a small
  60.  * structure it's best not to blow another stream for it (overhead).
  61.  */
  62. typedef struct tagTENANTINFO
  63.     {
  64.     DWORD       dwID;
  65.     RECTL       rcl;
  66.     FORMATETC   fe;     //Excludes ptd
  67.     } TENANTINFO, FAR *LPTENANTINFO;
  68.  
  69.  
  70. #define SZSTREAMTENANTLIST        "Tenant List"
  71.  
  72.  
  73.  
  74.  
  75. /*
  76.  * Page class describing an individual page and what things it contains,
  77.  * managing an IStorage for us.
  78.  *
  79.  * A DWORD is used to identify this page as the name of the storage
  80.  * is the string form of this ID.  If we added a page every second,
  81.  * it would take 136 years to overrun this counter, so we can
  82.  * get away with saving it persistently.  I hope this software is
  83.  * obsolete by then.
  84.  */
  85.  
  86. class __far CPage : public IUnknown
  87.     {
  88.     friend class CIOleUILinkContainer;
  89.  
  90.     //CHAPTER13MOD
  91.     friend class CImpIOleItemContainer;
  92.     //End CHAPTER13MOD
  93.  
  94.     private:
  95.         HWND        m_hWnd;             //Pages window, same as CPages.
  96.         DWORD       m_dwID;             //Persistent DWORD identifier
  97.         LPSTORAGE   m_pIStorage;        //Sub-storage for this page.
  98.         DWORD       m_cOpens;           //Calls to FOpen.
  99.  
  100.         class CPages FAR *m_pPG;        //Pages window
  101.  
  102.         DWORD       m_dwIDNext;
  103.         DWORD       m_cTenants;
  104.         HWND        m_hWndTenantList;   //Listbox that manages our tenant list
  105.  
  106.         UINT        m_iTenantCur;
  107.         LPTENANT    m_pTenantCur;
  108.  
  109.         UINT        m_uHTCode;          //Last hit-test on mouse move.
  110.         UINT        m_uSizingFlags;     //Restrictions on sizing motion.
  111.         BOOL        m_fTracking;        //Tracking resize?
  112.         RECTL       m_rclOrg;           //Original before tracking
  113.         RECTL       m_rcl;              //Tracking rectangle.
  114.         RECTL       m_rclBounds;        //Boundaries for size tracking.
  115.         HDC         m_hDC;              //Tracking hDC.
  116.  
  117.         //CHAPTER13MOD
  118.         LPMONIKER           m_pmkFile;  //Document name
  119.         ULONG               m_cRef;
  120.         LPOLEITEMCONTAINER  m_pIOleItemContainer;
  121.         //End CHAPTER13MOD
  122.  
  123.     protected:
  124.         BOOL         FTenantGet(UINT, LPTENANT FAR *, BOOL);
  125.         //CHAPTER13MOD
  126.         BOOL         FTenantGetFromID(DWORD, LPTENANT FAR *, BOOL);
  127.         //End CHAPTER13MOD
  128.         BOOL         FTenantAdd(UINT, DWORD, LPTENANT FAR *);
  129.         LPDATAOBJECT TransferObjectCreate(LPPOINTL);
  130.  
  131.         //PAGEMOUS.CPP
  132.         BOOL         FSelectTenantAtPoint(UINT, UINT);
  133.         UINT         TenantFromPoint(UINT, UINT, LPTENANT FAR *);
  134.         BOOL         DragDrop(UINT, UINT, UINT);
  135.  
  136.     public:
  137.         CPage(DWORD, HWND, class CPages FAR *);
  138.         ~CPage(void);
  139.  
  140.         //CHAPTER13MOD
  141.         //IUnknown for delegation
  142.         STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
  143.         STDMETHODIMP_(ULONG) AddRef(void);
  144.         STDMETHODIMP_(ULONG) Release(void);
  145.         //End CHAPTER13MOD
  146.  
  147.         DWORD       GetID(void);
  148.         BOOL        FOpen(LPSTORAGE);
  149.         void        Close(BOOL);
  150.         BOOL        Update(void);
  151.         void        Destroy(LPSTORAGE);
  152.         UINT        GetStorageName(LPSTR);
  153.  
  154.         void        Draw(HDC, int, int, BOOL, BOOL);
  155.  
  156.         BOOL        TenantCreate(TENANTTYPE, LPVOID, LPFORMATETC
  157.                         , LPPATRONOBJECT, DWORD);
  158.         BOOL        TenantDestroy(void);
  159.         BOOL        TenantClip(BOOL);
  160.         BOOL        FQueryObjectSelected(HMENU);
  161.         void        ActivateObject(UINT);
  162.         void        ShowObjectTypes(BOOL);
  163.         void        NotifyTenantsOfRename(LPSTR, LPMONIKER);
  164.         BOOL        FQueryLinksInPage(void);
  165.  
  166.         //PAGEMOUSE.CPP
  167.         BOOL        OnRightDown(UINT, UINT, UINT);
  168.         BOOL        OnLeftDown(UINT, UINT, UINT);
  169.         BOOL        OnLeftDoubleClick(UINT, UINT, UINT);
  170.         BOOL        OnLeftUp(UINT, UINT, UINT);
  171.         void        OnNCHitTest(UINT, UINT);
  172.         BOOL        OnSetCursor(UINT);
  173.         void        OnMouseMove(UINT, int, int);
  174.     };
  175.  
  176. typedef CPage FAR * LPPAGE;
  177.  
  178.  
  179.  
  180. /*
  181.  * Structures to save with the document describing the device
  182.  * configuration and pages that we have.  This is followed by
  183.  * a list of DWORD IDs for the individual pages.
  184.  */
  185.  
  186. typedef struct __far tagDEVICECONFIG
  187.     {
  188.     DEVMODE     dm;
  189.     char        szDriver[CCHDEVICENAME];
  190.     char        szDevice[CCHDEVICENAME];
  191.     char        szPort[CCHDEVICENAME];
  192.     } DEVICECONFIG, FAR * LPDEVICECONFIG;
  193.  
  194.  
  195. typedef struct __far tagPAGELIST
  196.     {
  197.     DWORD       cPages;
  198.     DWORD       iPageCur;
  199.     DWORD       dwIDNext;
  200.     } PAGELIST, FAR *LPPAGELIST;
  201.  
  202.  
  203. //PAGEWIN.CPP
  204. LRESULT __export FAR PASCAL PagesWndProc(HWND, UINT, WPARAM, LPARAM);
  205. BOOL    __export FAR PASCAL AbortProc(HDC, int);
  206. BOOL    __export FAR PASCAL PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
  207. void                        RectConvertMappings(LPRECT, HDC, BOOL);
  208.  
  209.  
  210.  
  211. class __far CPages : public CWindow
  212.     {
  213.     friend LRESULT __export FAR PASCAL PagesWndProc(HWND, UINT, WPARAM, LPARAM);
  214.     friend BOOL    __export FAR PASCAL PrintDlgProc(HWND, UINT, WPARAM, LPARAM);
  215.  
  216.     friend class CPage;
  217.     friend class CTenant;
  218.     friend class CDropTarget;
  219.     friend class CImpIOleClientSite;
  220.     friend class CImpIAdviseSink;
  221.  
  222.     //CHAPTER13MOD
  223.     friend class CImpIOleItemContainer;
  224.     //End CHAPTER13MOD
  225.  
  226.     protected:
  227.         LPPAGE      m_pPageCur;             //Current page we're viewing
  228.         UINT        m_iPageCur;
  229.         UINT        m_cPages;               //Number of pages
  230.  
  231.         HWND        m_hWndPageList;         //Listbox that manages our page list
  232.         HFONT       m_hFont;                //Page font.
  233.         BOOL        m_fSystemFont;          //Is m_hFont system object?
  234.  
  235.         UINT        m_cx;                   //Usable page size in LOMETRIC
  236.         UINT        m_cy;
  237.  
  238.         UINT        m_xMarginLeft;          //Unusable page margins, LOMETRIC
  239.         UINT        m_xMarginRight;
  240.         UINT        m_yMarginTop;
  241.         UINT        m_yMarginBottom;
  242.  
  243.         UINT        m_xPos;                 //Current viewport scroll position.
  244.         UINT        m_yPos;                 //both in *PIXELS*
  245.  
  246.         DWORD       m_dwIDNext;             //Next ID for a page.
  247.         LPSTORAGE   m_pIStorage;            //Root storage of document.
  248.  
  249.         UINT        m_cf;                   //Application clipboard format.
  250.         BOOL        m_fDirty;
  251.  
  252.         BOOL        m_fDragSource;          //Drag-drop source==target
  253.         BOOL        m_fMoveInPage;          //Only moving in same page
  254.         BOOL        m_fLinkAllowed;         //Can allow lin